/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ucue.ptc.gco.ui;

import edu.ucue.ptc.gco.mdl.Empleado;
import edu.ucue.ptc.gco.ngc.EmpleadoManagerLocal;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;

/**
 *
 * @author Johnny
 */
@Named(value = "listaEmpleadoAction")
@SessionScoped
public class ListaEmpleadoAction implements Serializable {

    /**
     * Creates a new instance of listaEmpleadoAction
     */
    private List<Empleado> listaEmpleados;
    @Inject
    private EmpleadoManagerLocal empleadoManager;

    @PostConstruct
    public void init() {
        actualizar();
    }

    /**
     * @return the listaCargos
     */
    public List<Empleado> getListaEmpleados() {
        return listaEmpleados;
    }

    /**
     * @param listaEmpleados the listaEmpelados to set
     */
    public void setListaEmpleados(List<Empleado> listaEmpleados) {
        this.listaEmpleados = listaEmpleados;
    }

    public void actualizar() {
        try {
            setListaEmpleados(empleadoManager.listarEmpleado("user", "user"));
       } catch (Exception e) {
            
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(e.getMessage()));
        }
    }
}
